﻿using Gadgeteer.Interfaces.Fakes;
using Gadgeteer.Interfaces.Fakes.net4;
using Microsoft.SPOT.Presentation.Media;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace Gadgeteer.Interfaces.Sample.PhotoCamera.CameraApp.Tests
{
    [TestFixture]
    public class CameraInteractionTest
    {
        private FakeMultiColorLed busyLed;
        private BusyIndicationStack busyStack;
        private FakeCamera camera;
        private FakeGraphics graphics;
        private DebugLogger logger;
        private FakeButton button;

        [SetUp]
        public void SetUp()
        {
            busyLed = new FakeMultiColorLed();
            busyStack = new BusyIndicationStack(busyLed);
            camera = new FakeCamera();
            graphics = new FakeGraphics();
            logger = new DebugLogger();
            button = new FakeButton();
        }

        [Test]
        public void ButtonPressForcesPicture()
        {
            var interaction = new CameraInteraction(busyStack, camera, graphics, button, logger);

            Assert.That(graphics.Current, Is.Null);
            Assert.That(busyLed.Color, Is.EqualTo(Color.Green));

            button.Press();
            Assert.That(busyStack.Busy);
            Assert.That(busyLed.Color, Is.EqualTo(Color.Red));

            Thread.Sleep(400);
            Assert.That(busyStack.Busy, Is.False);
            Assert.That(graphics.Current, Is.Not.Null);
            Assert.That(busyLed.Color, Is.EqualTo(Color.Green));
        }
    }
}
